package logic

import (
	"camera/B/Rpc/model/mysql"
	"context"
	"fmt"

	"camera/B/Rpc/camera"
	"camera/B/Rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateGoodsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateGoodsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateGoodsLogic {
	return &UpdateGoodsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateGoodsLogic) UpdateGoods(in *camera.UpdateGoodsRequest) (*camera.UpdateGoodsResponse, error) {
	// todo: add your logic here and delete this line
	g := mysql.Good{}
	err := g.UpdateStatus(int(in.Status), int(in.GoodId))
	if err != nil {
		return nil, fmt.Errorf("修改失败")
	}
	return &camera.UpdateGoodsResponse{
		Success: true,
	}, nil
}
